package com.moli.iov.protocol.enums;

/**
 *
 * Vehicle speed.
 *
 *  @author OAK
 *  @version 3.0.2
 *  @since 2019/10/14 19:38 PM.
 *
 */
public enum Speed implements IDictsEnumTag {

    /**
     * 上报数据是fe，解析为异常
     */
    FE("异常", (byte) -98),
    /**
     * 上报数据为ff，解析为无效
     */
    FF("无效", (byte) -99);


    private Speed(String key, byte value) {
        this.k = key;
        this.v = value;
    }

    private String k;

    private byte v;

    public static Speed valOf(byte value) {
        switch (value) {
            case -98:
                return FE;
            case -99:
                return FF;
            default:
                return null;
        }
    }

    public static String getKey(byte value) {
        for (Speed c : Speed.values()) {
            if (c.getV() == value) {
                return c.k;
            }
        }
        return "" + value;
    }

    @Override
    public IDictsEnumTag valueOf(byte pByte) {
        switch (pByte) {
            case -98:
                return FE;
            case -99:
                return FF;
            default:
                return null;
        }
    }

    @Override
    public String getK() {
        return k;
    }

    @Override
    public byte getV() {
        return v;
    }

}
